<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="../../../../lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.useso.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="../../../../lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="../../../../css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="../../../../images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="../../../../images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="../../../../images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="../../../../images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="git,gitlab,">










<meta name="description" content="系统：CentOS6.5 X86_64 已完成初始化：防火墙、SELinux 关闭、不必要服务停止，不必要用户删除……… 1.添加epel源 wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt &amp;amp;&amp;amp; rpm –import /etc/pki/rpm">
<meta name="keywords" content="git,gitlab">
<meta property="og:type" content="article">
<meta property="og:title" content="基于CentOS6.5 X86_64 源码搭建GitLab">
<meta property="og:url" content="http://demo_demo.gitee.io/2015/09/30/e5-9f-ba-e4-ba-8ecentos6-5-x86-64-e6-ba-90-e7-a0-81-e6-90-ad-e5-bb-bagitlab/index.html">
<meta property="og:site_name" content="运维人">
<meta property="og:description" content="系统：CentOS6.5 X86_64 已完成初始化：防火墙、SELinux 关闭、不必要服务停止，不必要用户删除……… 1.添加epel源 wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt &amp;amp;&amp;amp; rpm –import /etc/pki/rpm">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-information.png">
<meta property="og:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-login.png">
<meta property="og:updated_time" content="2018-12-10T10:49:03.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="基于CentOS6.5 X86_64 源码搭建GitLab">
<meta name="twitter:description" content="系统：CentOS6.5 X86_64 已完成初始化：防火墙、SELinux 关闭、不必要服务停止，不必要用户删除……… 1.添加epel源 wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 https://www.fedoraproject.org/static/0608B895.txt &amp;amp;&amp;amp; rpm –import /etc/pki/rpm">
<meta name="twitter:image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-information.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://demo_demo.gitee.io/2015/09/30/e5-9f-ba-e4-ba-8ecentos6-5-x86-64-e6-ba-90-e7-a0-81-e6-90-ad-e5-bb-bagitlab/">





  <title>基于CentOS6.5 X86_64 源码搭建GitLab | 运维人</title>
  








</head>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
<a href="https://github.com/guomaoqiu" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#FD6C6C; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">运维人</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">生命在于折腾</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://demo_demo.gitee.io">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="OutMan">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/myphoto.png">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="运维人">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">基于CentOS6.5 X86_64 源码搭建GitLab</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2015-09-30T15:31:43+08:00">
                2015-09-30
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="../../../../categories/Web相关/" itemprop="url" rel="index">
                    <span itemprop="name">Web相关</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>系统：CentOS6.5 X86_64 已完成初始化：防火墙、SELinux 关闭、不必要服务停止，不必要用户删除……… 1.添加epel源</p>
<p>wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 <a href="https://www.fedoraproject.org/static/0608B895.txt" target="_blank" rel="noopener">https://www.fedoraproject.org/static/0608B895.txt</a> &amp;&amp; rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6</p>
<p>#查看Key是否安装成功<br>rpm -qa gpg*</p>
<p>  2.安装epel源</p>
<p>rpm -Uvh <a href="http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm" target="_blank" rel="noopener">http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm</a></p>
<p>  3.添加PUIAS源</p>
<p>wget -O /etc/yum.repos.d/PUIAS_6_computational.repo <a href="https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS\_6\_computational.repo" target="_blank" rel="noopener">https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/install/centos/PUIAS\_6\_computational.repo</a></p>
<p>  4.下载并安装gpg-key</p>
<p>wget -O /etc/pki/rpm-gpg/RPM-GPG-KEY-puias <a href="http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias" target="_blank" rel="noopener">http://springdale.math.ias.edu/data/puias/6/x86_64/os/RPM-GPG-KEY-puias</a> &amp;&amp; rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-puias</p>
<p>#查看源是否添加成功[如果不成功，执行：yum-config-manager –enable epel –enable PUIAS_6_computational]<br>yum repolist</p>
<p>  5.安装整个搭建gitlab的相关的依赖包</p>
<p>yum -y groupinstall ‘Development Tools’<br>yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes git cmake libcom_err-devel.i686 libcom_err-devel.x86_64 nodejs</p>
<p>  6.配置默认编辑器</p>
<p>yum -y install vim-enhanced<br>update-alternatives –set editor /usr/bin/vim.basic<br>ln -s /usr/bin/vim /usr/bin/edito</p>
<p>#reStructuredText markup语法支持，需要安装依赖包：<br>yum install -y python-docutils</p>
<p>  7.安装git(git&gt;=1.7.10 如果低于我们可以从新编译安装)</p>
<p>yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel<br>mkdir /tmp/git &amp;&amp; cd /tmp/git<br>curl –progress <a href="https://www.kernel.org/pub/software/scm/git/git-2.1.3.tar.gz" target="_blank" rel="noopener">https://www.kernel.org/pub/software/scm/git/git-2.1.3.tar.gz</a> | tar xz<br>cd git-2.1.3/ &amp;&amp; ./configure –prefix=/usr/local/git &amp;&amp; make &amp;&amp; make install</p>
<p>  8.安装ruby(如果系统中Ruby的版本是2.0以前的那么请移除，GitLab只支持Ruby 2.0+版本)</p>
<p>yum remove ruby</p>
<p>mkdir /tmp/ruby &amp;&amp; cd /tmp/ruby<br>curl –progress <a href="ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz" target="_blank" rel="noopener">ftp://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.gz</a> | tar xz<br>cd ruby-2.1.2<br>./configure –prefix=/usr/local/ –disable-install-rdoc<br>make<br>make install</p>
<p>#记得检查ruby的版本是否是最新<br>ruby –version</p>
<p>  9.安装Bundler Gem(由于`<a href="http://rubygems.org\`已被墙，这里替换源为\`https://ruby.taobao.org\`" target="_blank" rel="noopener">http://rubygems.org\`已被墙，这里替换源为\`https://ruby.taobao.org\`</a>)</p>
<p># 添加淘宝源并且移除官方源<br>gem sources -a <a href="https://ruby.taobao.org" target="_blank" rel="noopener">https://ruby.taobao.org</a><br>gem sources -r <a href="https://rubygems.org/" target="_blank" rel="noopener">https://rubygems.org/</a></p>
<p>  10.安装Bundler</p>
<p>gem install bundler -v’1.5.2’ –no-doc</p>
<p>  11.System Users为GitLab创建用户</p>
<p>adduser –system –shell /bin/bash –comment ‘GitLab’ –create-home –home-dir /home/git/ git</p>
<p>  12.编辑sudoers文件，将ruby和git的程序路径添加到PATH中，使git用户作为root来使用gem命令</p>
<p>sed -ie ‘s@Defaults\    secure_path\ \=\ \/sbin\:\/bin\:\/usr\/sbin\:\/usr\/bin@Defaults\    secure_path\ \=\ \/sbin\:\/bin\:\/usr\/sbin\:\/usr\/bin\:/usr\/local\/bin@g’ /etc/sudoers</p>
<p>  13.安装mysql</p>
<p>yum install -y mysql mysql-devel mysql-server<br>service mysqld start</p>
<p>#为gitlab创建数据库</p>
<p>#创建用户<br>mysql -e “CREATE USER ‘git‘@’localhost’ IDENTIFIED BY ‘xxxxx’;”</p>
<p>#创建数据库<br>mysql -e “CREATE DATABASE IF NOT EXISTS \`gitlabhq_production\` DEFAULT CHARACTER SET \`utf8\` COLLATE \`utf8_unicode_ci\`;”</p>
<p>#授权<br>mysql -e “GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON \`gitlabhq_production\`.* TO ‘git‘@’localhost’;”</p>
<p>#用git用户尝试登陆验证是否成功<br>sudo -u git -H mysql -u git -pxxxxxx  -e ‘show databases;’</p>
<p>#记得要给root用户密码哦。</p>
<p>  14.安装redis(已经在前面的依赖包安装时安装了)</p>
<p>chkconfig redis on</p>
<p>#配置Redis使用sockets<br>cp /etc/redis.conf /etc/redis.conf.orig</p>
<p># 关闭Redis 监听于TCP<br>sed ‘s/^port .*/port 0/‘ /etc/redis.conf.orig | sudo tee /etc/redis.conf</p>
<p>#启用Redis socket<br>echo ‘unixsocket /var/run/redis/redis.sock’ | sudo tee -a /etc/redis.conf<br>echo -e ‘unixsocketperm 0770’ | sudo tee -a /etc/redis.conf</p>
<p>#设置socket目录属主（组）为redis<br>chown redis:redis /var/run/redis<br>chmod 755 /var/run/redis</p>
<p>#将git用户添加至redis组<br>usermod -aG redis git</p>
<p>#启动redis服务<br>service redis start</p>
<p>  15.安装gitlab，以及相关配置</p>
<p>cd /home/git/<br>sudo -u git -H git clone <a href="http://git.oschina.net/Yxnt/gitlab" target="_blank" rel="noopener">http://git.oschina.net/Yxnt/gitlab</a></p>
<p># 配置gitlab<br>cd /home/git/gitlab &amp;&amp; sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml</p>
<p>#访问地址为本机IP<br>sudo -u git -H sed -ie “s/host: .*/host: `hostname –all-ip-addresses`/g” config/gitlab.yml</p>
<p>#创建satellites目录<br>sudo -u git -H mkdir /home/git/gitlab-satellites &amp;&amp; chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites</p>
<p>#确认gitlab可以写入tmp/pids、tmp/sockets以及public/uploads/目录<br>chmod -R u+rwX tmp/pids/ &amp;&amp; chmod -R u+rwX tmp/sockets/ &amp;&amp; chmod -R u+rwX  public/uploads</p>
<p>#复制Unicorn配置文件<br>sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb</p>
<p>#复制Rack attack配置文件<br>sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb</p>
<p>#配置Git 全局设置<br>sudo -u git -H git config –global user.name “GitLab”<br>sudo -u git -H git config –global user.email “<a href="mailto:example@example.com" target="_blank" rel="noopener">example@example.com</a>“<br>sudo -u git -H git config –global core.autocrlf input</p>
<p>#配置Redis连接设置<br>sudo -u git -H cp config/resque.yml.example config/resque.yml<br>sudo -u git -H sed -ie “s/develo.*/development:\ unix:\/var\/run\/redis\/redis.sock/g” config/resque.yml</p>
<p>#配置Gitlab 数据库设置（注意这里的socket文件位置，不同版本的mysql位置不一样)<br>sudo -u git cp config/database.yml.mysql config/database.yml<br>sudo -u git sed -ie “12s/password: \“secure password\“/password: $MYSQL_PASS/g” config/database.yml<br>sudo -u git sed -ie “13,14s/#\ //g” config/database.yml<br>sudo -u git sed -ie “14s@socket: \/tmp\/mysql.sock@socket: \/var\/lib/mysql\/mysql.sock@g” config/database.yml</p>
<p>#确定database.yml文件只为git用户可读<br>sudo -u git -H chmod o-rwx config/database.yml</p>
<p>  16.安装Gems</p>
<p>cd /home/git/gitlab</p>
<p>#更换配置文件中的ruby源<br>sudo -u git -H sed -ie “s@source\ \“http:\/\/rubygems.org\“@source\ \“http:\/\/ruby.taobao.org\“@g” ../gitlab-shell/Gemfile</p>
<p>#安装<br>sudo -u git -H bundle install –deployment –without development test postgres aws</p>
<p>  17.安装,配置gitlab-shell</p>
<p>cd /home/git/gitlab/<br>sudo -u git -H bundle exec rake gitlab:shell:install[v2.6.3] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production</p>
<p>#配置(在安装过程中其实gitlab-shell配置已经自动生成了，但是有必要检查核实一下里面的配置，尤其是gitlab_url)<br>cp /home/git/gitlab-shell/config.yml /home/git/gitlab-shell/config.yml.bak</p>
<p>  18.初始化数据并且激活高级特性</p>
<p>#这里会提示输入yes/no，输入yes即可（我这里直接传递一个yes过去）<br>echo yes| sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production</p>
<p>#这里会生成一个账户和密码：</p>
<p>#login………root</p>
<p>#password……5iveL!fe 这个密码可以更改： sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=YOUR_NETPASSWORD</p>
<p>#生成js.css等文件（如果没有这一步的话，你在访问时网页css等是乱的）<br>cd /home/git/gitlab<br>bundle exec rake assets:precompile RAILS_ENV=production</p>
<p>  19.安装gitlab启动管理脚本</p>
<p>wget -O /etc/init.d/gitlab <a href="https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn" target="_blank" rel="noopener">https://gitlab.com/gitlab-org/gitlab-recipes/raw/master/init/sysvinit/centos/gitlab-unicorn</a><br>chmod +x /etc/init.d/gitlab<br>chkconfig –add gitlab<br>chkconfig gitlab on</p>
<p>#设置gitlab服务的日志滚动<br>cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab</p>
<p>  20.检查应用程序状态</p>
<p>sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production</p>
<p>#执行该命令 如果顺利的话，会将关于gitlab的 相关详细信息展示出来</p>
<p>和下图差不多 <a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-information.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-information.png" alt="gitlab-information"></a>   21.启动gitlab</p>
<p>#启动gitlab<br>service gitlab start</p>
<p>  22.安装nginx ，将访问请求反代到后端的8080端口</p>
<p>yum install -y nginx &amp;&amp; chkconfig nginx on</p>
<p>#删除nginx中的这个默认配置文件<br>rm -rf /etc/nginx/conf.d/default.conf</p>
<p>#获取gitlab的nginx模板配置文件<br>wget -O /etc/nginx/conf.d/gitlab.conf <a href="https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab" target="_blank" rel="noopener">https://gitlab.com/gitlab-org/gitlab-ce/raw/master/lib/support/nginx/gitlab</a></p>
<p>#对模板文件的一些修改<br>sed -ie “38s/.*/server\ localhost:8080;/g” /etc/nginx/conf.d/gitlab.conf<br>sed -ie “s/YOUR_SERVER_FQDN/`hostname`/g” /etc/nginx/conf.d/gitlab.conf<br>sed -ie “52d” /etc/nginx/conf.d/gitlab.conf</p>
<p>#将用户nginx加入到git组(这步非常的关键)<br>usermod -a -G git nginx<br>chmod g+rx /home/git/</p>
<p>#启动nginx<br>service nginx start</p>
<p>  ok ，至此gitlab的安装已经结束。我们通过<a href="http://YOUR-SERVER-IP/" target="_blank" rel="noopener">http://YOUR-SERVER-IP/</a> 就可以访问到你的gitlab平台了 <a href="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-login.png" target="_blank" rel="noopener"><img src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/2015/09/gitlab-login.png" alt="gitlab-login"></a></p>

      
    </div>
    
    
    
<div>
  
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>


  
</div>
    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="../../../../tags/git/" rel="tag"># git</a>
          
            <a href="../../../../tags/gitlab/" rel="tag"># gitlab</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="../../19/e9-80-9a-e8-bf-87inode-e5-88-a0-e9-99-a4linux-e4-b8-8b-e7-9a-84-e6-96-87-e4-bb-b6/" rel="next" title="通过Inode删除linux下的文件">
                <i class="fa fa-chevron-left"></i> 通过Inode删除linux下的文件
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="../../../10/16/e6-a3-80-e6-9f-a5-e6-96-87-e4-bb-b6-e6-97-b6-e9-97-b4-e6-88-b3-ef-bc-8c-e5-af-b9-e6-af-94-e6-97-b6-e9-97-b4-e7-9a-84shell-e8-84-9a-e6-9c-ac/" rel="prev" title="检查文件时间戳，对比时间的Shell脚本">
                检查文件时间戳，对比时间的Shell脚本 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="https://raw.githubusercontent.com/guomaoqiu/myblog_backup/master/uploads/myphoto.png" alt="OutMan">
            
              <p class="site-author-name" itemprop="name">OutMan</p>
              <p class="site-description motion-element" itemprop="description">😊</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="../../../../archives/">
              
                  <span class="site-state-item-count">79</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="../../../../categories/index.html">
                  <span class="site-state-item-count">22</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="../../../../tags/index.html">
                  <span class="site-state-item-count">46</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/guomaoqiu" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i></a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:guomaoqiu@google.com" target="_blank" title="E-Mail">
                      
                        <i class="fa fa-fw fa-envelope"></i></a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">OutMan</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="../../../../lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="../../../../lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="../../../../js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="../../../../js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="../../../../js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="../../../../js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="../../../../js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="../../../../js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="../../../../js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
